﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using CoreEx.Database.Linq.Translators;
using CoreEx.Database.Query.Expressions;
using LinFu.IoC.Configuration;
using LinFu.IoC;

namespace CoreEx.Database.Linq.Implementation.Translators
{
    [Implements(typeof(IExpressionTranslator_generic<MethodCallExpression>), ServiceName = "Any")]
    public class AnyMethodCallExpressionTranslator : MethodCallExpressionTranslatorGeneric
    {
        public AnyMethodCallExpressionTranslator(TranslateResult translateResult) : base(translateResult)
        {
        }

        public override DbExpression Translate(MethodCallExpression expression)
        {
            var expressionTranslator = ServiceContainer.GetService<IQueryTranslator>(TranslateResult.ConnectionName);
            
            var memberExpression = (MemberExpression)expression.Arguments[0];
            var outerTableSource = GetTableSource(memberExpression);
            var outerPersistentMember = outerTableSource.MappedProperties[(PropertyInfo) memberExpression.Member];

            var result = expressionTranslator.Translate(expression);

            

                        

            

            throw new NotImplementedException();
        }
    }
}
